var util = require('../../libs/util.js');
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    dataList:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (e) {
    var that = this;
     if(e.date){
       that.setData({
         date: e.date
       })
    } 
    if (e.carrier) {
      that.setData({
        carrier: e.carrier
      })
    }
    if (e.date) {
      that.setData({
        date: e.date
      })
    }
    if (e.warehouse) {
      that.setData({
        warehouse: e.warehouse
      })
    }
    if (e.warehouseName) {
      that.setData({
        warehouseName: e.warehouseName
      })
    }
    if (e.vehicle) {
      that.setData({
        vehicle: e.vehicle
      })
    }
    if (e.plate) {
      that.setData({
        plate: e.plate
      })
    }
    if (e.driver) {
      that.setData({
        driver: e.driver
      })
    } 
    if (e.driverName) {
      that.setData({
        driverName: e.driverName
      })
    }
    that.getData()
  },
  getData: function () {
    wx.showLoading({
      title: '加载数据中...',
    });
    var that = this;
    try {
      if (that.data.calendar) {
        console.log(that.data.date)
      }
    } catch (e) { }
    util.getData("/atapi/delivery/delivery/deliveryListOfShow", {
      CO_ID: app.globalData.CO_ID,
      date: that.data.date,
      warehouse: that.data.warehouse,
      vehicle: that.data.vehicle,
      driver: that.data.driver,
      carrier: that.data.carrier
    }, function (res, error) {
      console.log(res.data)
      wx.hideLoading();
      if (res.data.success) {
        that.setData({
          dataList: res.data.data
        })
      } else {
        that.setData({
          dataList: []
        })
      }
    });
  },
  showDeliveryDetail: function (e) {
    var that = this;
    var id = e.currentTarget.id;
    wx.navigateTo({
      url: '/pages/order/order?id=' + id
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})